package com.bbs.admin.user;

import com.bbs.user.User;
import com.bbs.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/page/user")
public class UserPageController {

    @Autowired
    UserService userService;

    @RequestMapping("list")
    public String list(){
        return "admin/user/list";
    }

    @RequestMapping("updateUser")
    public ModelAndView updateUser(ModelAndView mv,Integer id){
        User user =  userService.selectUserById(id);
        mv.addObject("user",user);
        mv.setViewName( "admin/user/update");
        return mv;
    }

    
    @RequestMapping("showAddUser")
    public String showAddUser(){
        return "admin/user/add";
    }

    @RequestMapping(value = "goRePass" ,method = RequestMethod.GET)
    public ModelAndView goRePass(ModelAndView mv,@RequestParam("id") Integer id){
        User user =  userService.selectUserById(id);
        mv.addObject("user",user);
        mv.setViewName( "admin/user/changePwd");
        return mv;
    }

}
